//
//  CellForWHTStoryOneModel.m
//  WZLProduct
//
//  Created by dllo on 16/3/28.
//  Copyright © 2016年 HaiTeng. All rights reserved.
//

#import "CellForWHTStoryOneModel.h"
#import "WHTStoryOneModel.h"
@interface CellForWHTStoryOneModel ()
@property (nonatomic, strong) UIView *separatorView; /**< 自定义分割线 */
@end

@implementation CellForWHTStoryOneModel

- (void)setModel:(DetaiPageBaseModel_Ht *)model{
    [super setModel:model];
    //之后赋值可以这样
    WHTStoryOneModel *modelOne = (WHTStoryOneModel *)model;
    self.userName.text = modelOne.userName;
    [self.userImg sd_setImageWithURL:[NSURL URLWithString:modelOne.userImage] placeholderImage:[UIImage imageNamed:@"refreshingImages"]];
    self.text.text = modelOne.text;
    
    
    NSString *poiButtonStr = [NSString stringWithFormat:@"故事发生在 %@",modelOne.poiName];
    [self.poiButton setTitle:poiButtonStr forState:UIControlStateNormal];
//关键字高亮
    self.poiButton.titleLabel.attributedText = [RequestData exchangeStr:poiButtonStr AttributedStr:modelOne.poiName Font:13 Color:[UIColor orangeColor]];

    
}




- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.userImg = [[UIImageView alloc] init];
        [self.contentView addSubview:self.userImg];
        self.userImg.image = [UIImage imageNamed:@"refreshingImages"];
        self.userImg.layer.masksToBounds = YES;
        self.userImg.layer.cornerRadius = 25;
        [self.userImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.equalTo(self.contentView).with.offset(10);
            make.size.mas_equalTo(50);
            
        }];
        
        self.userName = [[UILabel alloc] init];
        [self.contentView addSubview:self.userName];
        [self.userName setFont:[UIFont fontWithName:@"Helvetica-Bold" size:15]];
        [self.userName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.userImg);
            make.left.equalTo(self.userImg.mas_right).with.offset(5);
            make.right.equalTo(self.contentView).with.offset(-10);
            make.height.equalTo(self.userImg.mas_height).multipliedBy(0.5);
        }];
        
        self.poiButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.contentView addSubview:self.poiButton];
        self.poiButton.tintColor = kAppearanceColor;
        self.poiButton.titleLabel.font = FONT12;
        self.poiButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
        [self.poiButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.userName.mas_bottom);
            make.left.equalTo(self.userName);
            make.size.equalTo(self.userName);
        }];
        
        self.separatorView = [[UIView alloc] init];
        [self.contentView addSubview:self.separatorView];
        self.separatorView.backgroundColor = [UIColor grayColor];
        [self.separatorView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.userImg.mas_bottom).with.offset(15);
            make.left.equalTo(self.contentView).with.offset(10);
            make.right.equalTo(self.contentView).with.offset(-10);
            make.height.mas_equalTo(1);
        }];
        
        self.text = [[UILabel alloc] init];
        self.text.font = FONT20;
        self.text.numberOfLines = 0;
        [self.contentView addSubview:self.text];
        [self.text mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.left.equalTo(self.separatorView);
            make.top.equalTo(self.separatorView.mas_bottom).with.offset(15);
            make.height.mas_equalTo(50);
        }];
        
    }
    return self;
}


@end
